// -----------------------------
// Author: 		Dhaenens Gert	
// Creation: 	9/24/2014 3:09:29 PM				
// -----------------------------

#include "LuaVariable.h"

#include <string>

namespace ObjectLua
{

	LuaVariable::LuaVariable(Lua* lpLua, LuaScript* lpScript, const char* Name, LuaRef ref)
		: m_lpLua(lpLua)
		, m_lpScript(lpScript)
		, m_Name(nullptr)
		, m_Ref(ref)
	{
		size_t strLen = strnlen_s(Name, 512) + 1;
		m_Name = new char[strLen];
		strcpy_s(m_Name, strLen, Name);
	}
	LuaVariable::LuaVariable(const LuaVariable& refLuaVariable)
		: m_lpLua(refLuaVariable.m_lpLua)
		, m_lpScript(refLuaVariable.m_lpScript)
		, m_Ref(refLuaVariable.m_Ref)
		, m_Name(nullptr)
	{
		size_t strLen = strnlen_s(refLuaVariable.m_Name, 512) + 1;
		m_Name = new char[strLen];
		strcpy_s(m_Name, strLen, refLuaVariable.m_Name);
	}
	LuaVariable& LuaVariable::operator=(const LuaVariable& refLuaVariable)
	{
		m_lpLua = refLuaVariable.m_lpLua;
		m_lpScript = refLuaVariable.m_lpScript;
		m_Ref = refLuaVariable.m_Ref;

		size_t strLen = strnlen_s(refLuaVariable.m_Name, 512) + 1;
		m_Name = new char[strLen];
		strcpy_s(m_Name, strLen, refLuaVariable.m_Name);

		return (*this);
	}
	LuaVariable::~LuaVariable()
	{
		delete[] m_Name;
	}

}